//index.js 
const app = getApp()
Page({
  data: {
    indicatorDots: false,
    autoplay: false,
    interval: 5000,
    duration: 1000,
    item: {},
    arrlist: [],//所以数据
    arrhd: [],//头部数据
    arrcont: [],//获取员工信息
    cid: "",
    MusicArr: [],//音乐
    ismusic: true,//音乐是否播放
    lyshow: false,//模态框 
    Phone: '',//手机号
  },
  onLoad: function (options) {
    this.EmpDetail();

  }, 
  EmpDetail:function(){
    var _this = this; 
    app.http.POST("/MiniManagerEmp/EmpDetail",{}, (err, data) => {
      console.log("data", data.data);
        if(data.code==1){
            _this.setData({
              "arrlist":data.data
            })
        } else if(data.code==2){
          wx.showToast({
            title: data.msg,
            icon: 'none',
            duration: 2000
          })
          }else {
          wx.showToast({
            title: '请求失败',
            icon: 'none',
            duration: 2000
          })
        }
      
    })

  },

  //点击查看图片
  clickimgsdeilt: function (e) {
    console.log(e);
    var index = e.currentTarget.dataset.index;
    console.log(index)
    var arr = this.data.arrlist.OpusUrls; 
    wx.previewImage({
      current: arr[index], // 当前显示图片的http链接
      urls: arr,
    })
  },
 
  clarlyer: function () {
    this.setData({
      "lyshow": false
    })
  },
  //点击打开弹窗
  clickleyr: function (e) {
    var ipone = e.currentTarget.dataset.item;
    this.setData({
      "lyshow": true,
      "Phone": ipone
    })
  },
  //拨打电话
  clickCall: function (e) {
    var ipone = e.currentTarget.dataset.item;
    wx.makePhoneCall({
      phoneNumber: ipone
      
    })
  },
  //保存电话号码
  clickPhone: function (e) {
    var ipone = e.currentTarget.dataset.item;
    var name = e.currentTarget.dataset.name;
    wx.addPhoneContact({
      firstName:name,
      mobilePhoneNumber: ipone
    })
  },
  //复制微信号
  clickCopy: function (e) {
    var wxnumber = e.currentTarget.dataset.item;
    wx.setClipboardData({
      data: wxnumber,
      success: function (res) {
        wx.getClipboardData({
          success: function (res) {
            wx.showToast({
              title: '复制成功',
              icon: 'success',
              duration: 2000
            })
          }
        })
      }
    })
  },
  notlak:function(e){
    wx.showModal({
      title: '提示',
      showCancel:false,
      content: '不能预约自己',
      success: function (res) {
        
      }
    })
  },
  //查看路线
  clickway: function (e) { 
    
    var idress = e.currentTarget.dataset.idress;
    var Latitude = e.currentTarget.dataset.Latitude;
    var Longitude = e.currentTarget.dataset.Longitude;
    if (!idress) {
      return;
    } 
    wx.openLocation({
      latitude: Number(Latitude),
      longitude: Number(Longitude),
      address: idress,
      scale: 28
    }); 
  }, 
  /**
    * 生命周期函数--监听页面初次渲染完成
    */
  onReady: function (e) {
    wx.setNavigationBarTitle({
      title: '名片'
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    var arrcont = this.data.arrcont;
    return {
      title: arrcont.NickName + "的美名片",
      path: "/pages/index/index?cid=" + this.data.cid,
      success: function (res) {
        wx.showToast({
          title: '分享成功',
          icon: "success",
          duration: 200
        })
      }
    }
  }
})